// vue-4.x：
import { createRouter, createWebHistory } from 'vue-router';

// import { createRouter, createWebHashHistory } from 'vue-router';

import ComA from "../components/02router/com-a";

// 配置路由规则
const routes = [
    {
        path: "/coma",
        name: "coma",
        // component配置方式一：配置组件对象
        component: ComA,
    },
    {
        // 以下都OK: /comb /Comb /COMB /COMB/
        // 如果sensitive为true: /comb /comb/
        // 如果strict为true: /comb /COMB 不行：/comb/
        path: "/comb", 
        name: "comb",
        // component配置方式二：一个函数，返回reslove组件的Promise对象
        component: () => import("../components/02router/com-b"),
    },
    {
        path: "/comc/:name/:age",
        name: "comc",
        component: () => import("../components/02router/com-c"),
    },
    {
        path: "/comd",
        name: "comd",
        component: () => import("../components/02router/com-d"),
    },
    {
        path: "/come/:name/:age",
        name: "come",
        component: () => import("../components/02router/com-e"),
        // props：传递一个函数，返回一个对象，对象上的所有属性会被挂载到props上
        props: route => ({...route.params,...route.query})
    }
]

// 创建路由对象
const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes
})

// 导出路由对象
export default router;